// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.MachineLearning;

public sealed partial class DataframeEvaluationClassification
{
	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("actual_field")]
	public Elastic.Clients.Elasticsearch.Field ActualField { get; set; }

	/// <summary>
	/// <para>Specifies the metrics that are used for the evaluation.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("metrics")]
	public Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetrics? Metrics { get; set; }

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("predicted_field")]
	public Elastic.Clients.Elasticsearch.Field? PredictedField { get; set; }

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("top_classes_field")]
	public Elastic.Clients.Elasticsearch.Field? TopClassesField { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluation(DataframeEvaluationClassification dataframeEvaluationClassification) => Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluation.Classification(dataframeEvaluationClassification);
}

public sealed partial class DataframeEvaluationClassificationDescriptor<TDocument> : SerializableDescriptor<DataframeEvaluationClassificationDescriptor<TDocument>>
{
	internal DataframeEvaluationClassificationDescriptor(Action<DataframeEvaluationClassificationDescriptor<TDocument>> configure) => configure.Invoke(this);

	public DataframeEvaluationClassificationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field ActualFieldValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetrics? MetricsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor MetricsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor> MetricsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Field? PredictedFieldValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? TopClassesFieldValue { get; set; }

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> ActualField(Elastic.Clients.Elasticsearch.Field actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> ActualField<TValue>(Expression<Func<TDocument, TValue>> actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> ActualField(Expression<Func<TDocument, object>> actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>Specifies the metrics that are used for the evaluation.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetrics? metrics)
	{
		MetricsDescriptor = null;
		MetricsDescriptorAction = null;
		MetricsValue = metrics;
		return Self;
	}

	public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor descriptor)
	{
		MetricsValue = null;
		MetricsDescriptorAction = null;
		MetricsDescriptor = descriptor;
		return Self;
	}

	public DataframeEvaluationClassificationDescriptor<TDocument> Metrics(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor> configure)
	{
		MetricsValue = null;
		MetricsDescriptor = null;
		MetricsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> PredictedField(Elastic.Clients.Elasticsearch.Field? predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> PredictedField<TValue>(Expression<Func<TDocument, TValue>> predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> PredictedField(Expression<Func<TDocument, object>> predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> TopClassesField(Elastic.Clients.Elasticsearch.Field? topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> TopClassesField<TValue>(Expression<Func<TDocument, TValue>> topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor<TDocument> TopClassesField(Expression<Func<TDocument, object>> topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("actual_field");
		JsonSerializer.Serialize(writer, ActualFieldValue, options);
		if (MetricsDescriptor is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, MetricsDescriptor, options);
		}
		else if (MetricsDescriptorAction is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor(MetricsDescriptorAction), options);
		}
		else if (MetricsValue is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, MetricsValue, options);
		}

		if (PredictedFieldValue is not null)
		{
			writer.WritePropertyName("predicted_field");
			JsonSerializer.Serialize(writer, PredictedFieldValue, options);
		}

		if (TopClassesFieldValue is not null)
		{
			writer.WritePropertyName("top_classes_field");
			JsonSerializer.Serialize(writer, TopClassesFieldValue, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class DataframeEvaluationClassificationDescriptor : SerializableDescriptor<DataframeEvaluationClassificationDescriptor>
{
	internal DataframeEvaluationClassificationDescriptor(Action<DataframeEvaluationClassificationDescriptor> configure) => configure.Invoke(this);

	public DataframeEvaluationClassificationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Field ActualFieldValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetrics? MetricsValue { get; set; }
	private Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor MetricsDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor> MetricsDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.Field? PredictedFieldValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? TopClassesFieldValue { get; set; }

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor ActualField(Elastic.Clients.Elasticsearch.Field actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor ActualField<TDocument, TValue>(Expression<Func<TDocument, TValue>> actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which contains the ground truth. The data type of this field can be boolean or integer. If the data type is integer, the value has to be either 0 (false) or 1 (true).</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor ActualField<TDocument>(Expression<Func<TDocument, object>> actualField)
	{
		ActualFieldValue = actualField;
		return Self;
	}

	/// <summary>
	/// <para>Specifies the metrics that are used for the evaluation.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor Metrics(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetrics? metrics)
	{
		MetricsDescriptor = null;
		MetricsDescriptorAction = null;
		MetricsValue = metrics;
		return Self;
	}

	public DataframeEvaluationClassificationDescriptor Metrics(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor descriptor)
	{
		MetricsValue = null;
		MetricsDescriptorAction = null;
		MetricsDescriptor = descriptor;
		return Self;
	}

	public DataframeEvaluationClassificationDescriptor Metrics(Action<Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor> configure)
	{
		MetricsValue = null;
		MetricsDescriptor = null;
		MetricsDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor PredictedField(Elastic.Clients.Elasticsearch.Field? predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor PredictedField<TDocument, TValue>(Expression<Func<TDocument, TValue>> predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field in the index which contains the predicted value, in other words the results of the classification analysis.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor PredictedField<TDocument>(Expression<Func<TDocument, object>> predictedField)
	{
		PredictedFieldValue = predictedField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor TopClassesField(Elastic.Clients.Elasticsearch.Field? topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor TopClassesField<TDocument, TValue>(Expression<Func<TDocument, TValue>> topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	/// <summary>
	/// <para>The field of the index which is an array of documents of the form { "class_name": XXX, "class_probability": YYY }. This field must be defined as nested in the mappings.</para>
	/// </summary>
	public DataframeEvaluationClassificationDescriptor TopClassesField<TDocument>(Expression<Func<TDocument, object>> topClassesField)
	{
		TopClassesFieldValue = topClassesField;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("actual_field");
		JsonSerializer.Serialize(writer, ActualFieldValue, options);
		if (MetricsDescriptor is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, MetricsDescriptor, options);
		}
		else if (MetricsDescriptorAction is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassificationMetricsDescriptor(MetricsDescriptorAction), options);
		}
		else if (MetricsValue is not null)
		{
			writer.WritePropertyName("metrics");
			JsonSerializer.Serialize(writer, MetricsValue, options);
		}

		if (PredictedFieldValue is not null)
		{
			writer.WritePropertyName("predicted_field");
			JsonSerializer.Serialize(writer, PredictedFieldValue, options);
		}

		if (TopClassesFieldValue is not null)
		{
			writer.WritePropertyName("top_classes_field");
			JsonSerializer.Serialize(writer, TopClassesFieldValue, options);
		}

		writer.WriteEndObject();
	}
}